// * localstorage 获取
import crypto from 'crypto';

export function get(data) {
  const result = localStorage.getItem(data);

  try {
    return JSON.parse(result);
  } catch (e) {
    return result;
  }
}

// * localstorage 放入
export function set(name, data) {
  localStorage.setItem(name, JSON.stringify(data));
}

/* 加密用户名，密码 */
export function encode(str) {
  const cipher = crypto.createCipher('aes192', 'deliveryIsen');
  let crypted = cipher.update(str, 'utf8', 'hex');
  crypted += cipher.final('hex');
  return crypted;
}
